import java.util.Scanner;

/**
 * 【程序7】   
 * 题目：输入一行字符，分别统计出其中英文字母、空格、数字和其它字符的个数。 
 */
public class test7 {
    public static void main(String[] args) {
        int enCharacter = 0;
        int space = 0;
        int number = 0;
        int spCharacter = 0;
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入一行字符：");
        String str = sc.nextLine();
        for (int i = 0; i < str.length(); i++) {
            char temp = str.charAt(i);
            if ((temp >= 'A' && temp <= 'Z') || (temp >= 'a' && temp <= 'z'))
                enCharacter++;
            else if (temp >= '0' && temp <= '9')
                number++;
            else if (temp == ' ')
                space++;
            else
                spCharacter++;
        }
        System.out.println("字符串中英文字母个数为：" + enCharacter
                + " 空格个数为：" + space + " 数字个数为：" + number
                + " 其他字符个数为： " + spCharacter);
    }
}
